#include<bits/stdc++.h>
using namespace std;
int main()
{
    freopen("duel.in","r",stdin);
    freopen("duel.out","w",stdout);
    int n,r[100000],p[100000],t=0;
    cin >> n;
    for(int i = 0;i<n;i++)
    {
        cin >> r[i];
    }
    for(int i = 0;i<n;i++)
    {
        if(r[i]<=r[i+1])
        {
            p[i]=r[i];
            p[i+1]=r[i+1];
        }
        else
        {
            p[i]=r[i+1];
            p[i+1]=r[i];
        }
    }
    for(int i=1;i<=n;i++)
    {
        if(p[i]=p[i+1])
        {
            t++;
        }
        else
        {
            break;
        }
    }
    cout<<t;
    return 0;
}
